dojo.provide("miaigo.model.PointSet");

dojo.declare(
    "miaigo.model.PointSet",
    null,
    {
	// Array of {x, y}
	points: null,

	constructor: function()
	{
	    this.points = new Array();
	},

	// add one point
	addPoint: function(x, y)
	{
	    if (!this.contains(x, y))
	    {
		var point = {x: x, y: y};
		this.points.push(point);
	    }
	},

	// accept an array of {x, y}, add them all
	addPoints: function(points)
	{
	    for (var i = 0; i < points.length; i++)
	    {
		if (!this.contains(points[i].x, points[i].y))
		    this.points.push(points[i]);
	    }
	},

	// test if the given point is in this block
	contains: function(x, y)
	{
	    for (i in this.points)
	    {
		if ((this.points[i].x == x) && (this.points[i].y == y))
		    return true;
	    }

	    return false;
	},

	getAllPoints: function()
	{
	    return this.points;
	}
    });